<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue-2.6.12.js"></script>
</head>
<body>
  <div id="app">
    <mytable :pros="products"></mytable>
  </div>
  <template id="mytable">
    <table border="1" align="center">
      <thead>
        <tr>
          <td>编号</td>
          <td>商品名</td>
          <td>价格</td>
        </tr>
      </thead>
      <thead>
        <tr v-for="(item,index) in pros" :key="index">
          <td>{{item.id}}</td>
          <td>{{item.name}}</td>
          <td>{{item.price}}</td>
        </tr>
      </thead>
    </table>
  </template>
  <script>
    
    var mytable = {
      template:"#mytable",
      // data:function (){
      //     return {
      //       products:[{id:1,name:"su7",price:21},{id:2,name:"byd",price:21}]
      //     };
      // }
      props:["pros"]
    };
    new Vue({
      el:"#app",
      components:{
        mytable
      },
      data:{
        products:[{id:1,name:"su7",price:21},{id:2,name:"byd",price:21}]
      }
    });
  </script>
</body>
</html>